#define _gam_globals_included 1

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>
#include <csx>
#include <hamsandwich>
#include <fakemeta>
#include <fakemeta_util>
#include <fun>

#pragma semicolon 1

#define PLUGIN "Great Army Mod"
#define VERSION "1.0"
#define AUTHOR "Zabijaka"


#define MAX_PLAYERS 32
#define MAX_KEY_LEN 32
#define ADMIN_SET_LEVEL ADMIN_CFG
#define OFFSET_LAST_HIT_GROUP      75
#define EXTRAOFFSET_PL_LINUX        5 

#define TASK_INVISIBILITY 100
#define TASK_GIVE_HE 133
#define TASK_DISPLAY_RANK 166

//{ ENUMS
enum _:SETTINGS{
	SETTINGS_DISP_RANK,
	SETTINGS_DISP_WPN_LVL,
	Float:SETTINGS_DISP_X,
	Float:SETTINGS_DISP_Y,
	SETTINGS_SHOW_LVL_ON_KILL,
	SETTINGS_SHOW_LVL_ON_WPN_CHANGE,
	SETTINGS_DISP_AFTER_KILL
}

enum _:WEAPONS {
	WEAPONS_BLANK = 0,
	WEAPONS_P228,
	WEAPONS_NOTHING,
	WEAPONS_SCOUT,
	WEAPONS_HEGRENADE,
	WEAPONS_XM1014,	//5
	WEAPONS_C4,
	WEAPONS_MAC10,
	WEAPONS_AUG,
	WEAPONS_SMOKEGRENADE,
	WEAPONS_ELITE,		//10
	WEAPONS_FIVESEVEN,
	WEAPONS_UMP45,
	WEAPONS_SG550,
	WEAPONS_GALIL,
	WEAPONS_FAMAS,		//15
	WEAPONS_USP,
	WEAPONS_GLOCK18,
	WEAPONS_AWP,
	WEAPONS_MP5NAVY,
	WEAPONS_M249,		//20
	WEAPONS_M3,
	WEAPONS_M4A1,
	WEAPONS_TMP,
	WEAPONS_G3SG1,
	WEAPONS_FLASHBANG,	//25
	WEAPONS_DEAGLE,
	WEAPONS_SG552,
	WEAPONS_AK47,
	WEAPONS_KNIFE,
	WEAPONS_P90		//30
}

enum _:XP_TYPE {
	T_ROUND,
	T_MAP,
	T_TOTAL
}
enum _:KILL_TYPE{
	KT_NORMAL,
	KT_HS
}
enum _:WEAPONS_LEVELS {
	LEVEL_NONE =0,
	LEVEL_BEGINNER,
	LEVEL_BASIC,
	LEVEL_ADVANCED,
	LEVEL_VETERAN,
	LEVEL_EXPERT,
	LEVEL_HITMAN,
	LEVEL_OWNER
}

enum _:RANKS {
	RANK_PRIVATE,
	RANK_OLDER_PRIVATE,
	RANK_FIRST_CLASS_PRIVATE,
	RANK_SPECJALIST,
	RANK_CORPORAL,
	
	RANK_SERGEANT,
	RANK_STAFF_SERGEANT,
	RANK_SERGEANT_FIRST_CLASS,
	RANK_MASTER_SERGEANT,
	RANK_FIRST_SERGEANT,
	
	RANK_SERGEANT_MAJOR,
	RANK_COMMAND_SERGEANT_MAJOR,
	RANK_SERGEANT_MAJOR_OF_THE_ARMY,
	RANK_SECOND_LIEUTENANT,
	RANK_FIRST_LIEUTENANT,
	
	RANK_CAPTAIN,	
	RANK_MAJOR,
	RANK_LIEUTENANT_COLONEL,
	RANK_COLONEL,
	RANK_BRIDAGIER_GENERAL,
	
	RANK_MAJOR_GENERAL,
	RANK_LIEUTENANT_GENERAL,
	RANK_GENERAL,
	RANK_GENERAL_OF_THE_ARMY
}


enum _:LEVEL_REQ{
	REQ_KILLS_ROUND,
	REQ_HS_ROUND,
	REQ_KILLS_MAP,
	REQ_HS_MAP,
	REQ_KILLS_TOTAL,
	REQ_HS_TOTAL
}

enum _:WEAPON_GROUP{
	GROUP_NONE,
	GROUP_PISTOLS,
	GROUP_SMG,
	GROUP_RIFELS,
	GROUP_SNIPERS,
	GROUP_SHOTGUNS,
	GROUP_OTHER,	//Knife he para
	GROUP_EXPLODE,
	GROUP_KNIFE,
	GROUP_PARA
}

//} ENUMS


//{ PLAYER INFO

new gPlayerKey[MAX_PLAYERS][MAX_KEY_LEN]; 		//Save key (Steam Id or Name)
new gPlayerInfo[MAX_PLAYERS][WEAPONS][LEVEL_REQ]; 	//Info on how many kills/hs user currently has
new gPlayerLevelInfo[MAX_PLAYERS][WEAPONS];		//User current weapons levels
new gPlayerLevelReq[MAX_PLAYERS][WEAPONS][LEVEL_REQ];	//Info on whitch requierments (kills/hs in round/map/total) user has acheaved to get to the next level

new gPlayerXp[MAX_PLAYERS][XP_TYPE];			//Players XP round/map/total
new gPlayerRank[MAX_PLAYERS];				//Player rank
new gPlayerVisibility[MAX_PLAYERS];
new gPlayerSettings[MAX_PLAYERS][SETTINGS];
new gPlayerSaveNeeded[MAX_PLAYERS];

new const RANK_REQ[RANKS] = {
	0,
	100,
	200,
	400,
	800,
	
	1300,
	2000,
	3000,
	4500,
	7000,
	
	10000,
	15000,
	22000,
	30000,
	40000,
	
	50000,
	60000,
	70000,
	80000,
	100000,
	
	120000,
	150000,
	180000,
	250000
};

//} PLAYER INFO 
//{WEAPONS GROUPS
/*
new WEAPONS_PISTOLS[] = {
	WEAPONS_P228,
	WEAPONS_ELITE,
	WEAPONS_FIVESEVEN,
	WEAPONS_DEAGLE,
	WEAPONS_USP,
	WEAPONS_GLOCK18
};
new WEAPONS_SHOTGUNS[] = {
	WEAPONS_XM1014,
	WEAPONS_M3
};
new WEAPONS_SNIPERS[] = {
	WEAPONS_SCOUT,
	WEAPONS_AWP//,
	//WEAPONS_G3SG1,
	//WEAPONS_SG550
};
new WEAPONS_SMG[] ={
	WEAPONS_MAC10,
	WEAPONS_UMP45,
	WEAPONS_MP5NAVY,
	WEAPONS_TMP,
	WEAPONS_P90
};
new WEAPONS_RIFELS[] = {
	WEAPONS_AUG,
	WEAPONS_GALIL,
	WEAPONS_FAMAS,
	WEAPONS_M4A1,
	WEAPONS_SG552,
	WEAPONS_AK47
};
new WEAPONS_OTHER[] ={
	WEAPONS_M249,
	WEAPONS_HEGRENADE,
	WEAPONS_KNIFE
};

*/
//} WEAPONS GROUPS

//{ CVARS
new gCvarActive;
new gCvarGamKey;
new gCvarXpKill;
new gCvarXpHs;
new gCvarXpKillHigherRank;
new gCvarXpRoundWinDead;
new gCvarXpRoundWinAlive;
new gCvarXpBestInRound;
new gCvarMinPlayers;
new gCvarShorterC4Time;
new gCvarLevelPowers;

//} CVARS
new gPCvarC4Timer;
new gC4Timer;
new Float:gBuyTime;
new Float:gFreezTime;
new Float:gRoundTime;


new gMaxPlayers;
new bool:gCtWin;
new gSyncHudObject;
new rankHud;

stock Float:getWeaponSpeed(wpn){
	switch(wpn){
		case WEAPONS_SCOUT: return 260.0;
		case WEAPONS_XM1014, WEAPONS_AUG, WEAPONS_GALIL, WEAPONS_FAMAS: return 240.0;
		case WEAPONS_SG550, WEAPONS_AWP, WEAPONS_G3SG1: return 210.0;
		case WEAPONS_M249: return 220.0;
		case WEAPONS_M3, WEAPONS_M4A1: return 230.0;
		case WEAPONS_SG552: return 235.0;
		case WEAPONS_AK47: return 221.0;
		case WEAPONS_P90: return 245.0;
	}
	return 250.0;
}

stock Float:getZoomWeaponSpeed(wpn){
	switch(wpn){
		case WEAPONS_SCOUT: return 220.0;
		case WEAPONS_AWP, WEAPONS_SG550, WEAPONS_G3SG1: return 150.0;
		case WEAPONS_AUG: return 240.0;
		case WEAPONS_SG552: return 235.0;
	}
	return 0.0;
}

stock getWeaponGroup(wpn){
	switch(wpn){
		case WEAPONS_P228,WEAPONS_ELITE,WEAPONS_FIVESEVEN,WEAPONS_DEAGLE,WEAPONS_USP,WEAPONS_GLOCK18: return GROUP_PISTOLS;
		case WEAPONS_MAC10,WEAPONS_UMP45,WEAPONS_MP5NAVY,WEAPONS_TMP,WEAPONS_P90: return GROUP_SMG;
		case WEAPONS_AUG,WEAPONS_GALIL,WEAPONS_FAMAS,WEAPONS_M4A1,WEAPONS_SG552,WEAPONS_AK47: return GROUP_RIFELS;
		case WEAPONS_SCOUT,WEAPONS_AWP,WEAPONS_G3SG1,WEAPONS_SG550: return GROUP_SNIPERS;
		case WEAPONS_XM1014,WEAPONS_M3: return GROUP_SHOTGUNS;
		case WEAPONS_M249,WEAPONS_HEGRENADE,WEAPONS_KNIFE: return GROUP_OTHER;
	}
	return GROUP_NONE;
}
stock setClientWeaponLevel(id, wpn, level) {
	gPlayerLevelReq[id][wpn] = {0,0,0,0,0,0};
	gPlayerLevelInfo[id][wpn] = level;
	if(id) {
		new lvlName[32];
		new wpnName[32];
		getLevelName(id, level, lvlName, 31);
		getWeaponName4Level(id, wpn, wpnName, 31);
		format(lvlName, 31, "^x03%s^x04", lvlName);
		format(wpnName, 31, "^x03%s^x04", wpnName);
		ColorChat(id, RED, "^x04%L", id, "PROMOTED_LEVEL", lvlName, wpnName);
	}
}

/*
pistolety: (6 broni) (zrobione)
LEVEL_BEGINNER:	+2 dmg do pistoletow
LEVEL_BASIC:	+3 dmg do pistoletow
LEVEL_ADVANCED:	+4 dmg do pistoletow
LEVEL_VETERAN:	+1% dmg do wszystkich broni
LEVEL_EXPERT:	+2% dmg do wszystkich broni, +1% szans na rozbrojenie wroga (wyrzuci trzymana bron)
LEVEL_HITMAN:	+3% dmg do wszystkich broni, +2% szans na rozbrojenie wroga (wyrzuci trzymana bron)
LEVEL_OWNER:	+3% dmg do wszystkich broni, +3% szans na rozbrojenie wroga (wyrzuci trzymana bron), 30% szansy na natychmiastowe zabicie headshotem

SMG: (5 broni) (zrobione)
LEVEL_BEGINNER 	+2% do predkosci strelania
LEVEL_BASIC 	+3% do predkosci strelania
LEVEL_ADVANCED	+3% do predkosci strelania, +2% do predkosci chodzenia
LEVEL_VETERAN	+3% do predkosci strelania, +3% do predkosci chodzenia
LEVEL_EXPERT	+3% do predkosci strelania, +4% do predkosci chodzenia
LEVEL_HITMAN	+4% do predkosci strelania, +4% do predkosci chodzenia, -3% do gravitacji
LEVEL_OWNER	+4% do predkosci strelania, +4% do predkosci chodzenia, -5% do gravitacji

RIFELS: (6 broni) 
LEVEL_BEGINNER	+10 pancerza
LEVEL_BASIC	+15 pancerza
LEVEL_ADVANCED	+20 pancerza, +5 hp
LEVEL_VETERAN	+25 pancerza, +6 hp
LEVEL_EXPERT 	+30 pancerza, +8 hp
LEVEL_HITMAN	+35 pancerza, +10 hp
LEVEL_OWNER	+35 pancerza, +15 hp


Sniper (zrobione)
Scout & AWP:
LEVEL_BEGINNER:	15% szansy na darmowego scouta
LEVEL_BASIC:	25% szansy na darmowego scouta
LEVEL_ADVANCED:	35% szansy na darmowego scouta
LEVEL_VETERAN:	50% szansy na darmowego scouta
LEVEL_EXPERT:	50% szansy na darmowego scouta, -5% do obrazen
LEVEL_HITMAN:	50% szansy na darmowego scouta, -10% do obrazen

AWP:
LEVEL_OWNER:	natychmiastowe zabicie z AWP + 10% mniejsze obrazenia + darmowy scout
Scount:
LEVEL_OWNER:	15% mniejsze obrazenia + darmowy scout, 50% szansy na natychmiastowe zabicie ze scouta

========================================================================

Shotguns (2 bronie) (zrobione)

LEVEL_BEGINNER:	-10% widzialnosci z nozem w czasie stania
LEVEL_BASIC:	-20% widzialnosci z nozem w czasie stania
LEVEL_ADVANCED:	-30% widzialnosci z nozem w czasie stania
LEVEL_VETERAN: 	-40% widzialnosci z nozem w czasie stania, -10%  widzialnosci z nozem w czasie ruchu
LEVEL_EXPERT:	-40% widzialnosci z nozem w czasie stania, -20%  widzialnosci z nozem w czasie ruchu
LEVEL_HITMAN:	-40% widzialnosci z nozem w czasie stania, -30%  widzialnosci z nozem w czasie ruchu
LEVEL_OWNER:	-40% widzialnosci z nozem w czasie stania, -40%  widzialnosci z nozem w czasie ruchu

noz:
LEVEL_BEGINNER:	+15 HP za zabicie nozem
LEVEL_BASIC:	+30 HP za zabicie nozem
LEVEL_ADVANCED:	+5 HP za zabicie dowolna bronia, +10 HP za Headshota
LEVEL_VETERAN:	+10 HP za zabicie dowolna bronia, +15 HP za Headshota
LEVEL_EXPERT:	Ciche chodzenie z nozem, +10 HP za zabicie dowolna bronia, +15 HP za Headshota
LEVEL_HITMAN:	Ciche chodzenie z nozem, +15 HP za zabicie dowolna bronia, +20 HP za Headshota, +50 HP za zabicie nozem
LEVEL_OWNER:	Natychmiastowe zabicie prawym przyciskiem myszy, Ciche chodzenie, +15 HP za zabicie dowolna bronia, +20 HP za Headshota

he: 
LEVEL_BEGINNER: 10% wieksze obrazenia od he
LEVEL_BASIC: 	20% wieksze obrazenia od he
LEVEL_ADVANCED: 30% wieksze obrazenia od he
LEVEL_VETERAN: 	moze kupic 2 he 15% wieksze obrazenia
LEVEL_EXPERT:	dostaje darmowe he na respie i 15 sekund po wyrzuceniu 10% wieksze obrazenia
LEVEL_HITMAN: 	zabici wybuchem bomby licza sie jako zabici granatem
LEVEL_OWNER:	LEVEL_HITMAN + LEVEL_EXPERT

*/


